import fetch from '@/utils/fetch'

export function getAffairSetting() {
	return fetch({
	    url: '/customer/v1/mgt/affair/setting',
	    method: 'get'
  	})
}

export function setAffairSetting(data) {
	return fetch({
	    url: '/customer/v1/mgt/affair/setting',
	    method: 'patch',
	    data
  	})
}

//获取用户报修信息列表(小区id+工单类型)
export function getRepairList(id,params){
	return fetch({
		url:`/customer/v1/mgt/repair/repairaffairs_byareaid/${id}`,
		method:"get",
		params
	})
}

//上报类型
export const sourceOfEvents={
	0:"APP",
	1:"APP",
	2:"800呼",
	3:"自动报警"
}

//事务状态
export const affairStatus={
	0:"工单创建",
	1:"未分配",
	2:"分配待处理",
	3:"处理完成，待评价",
	4:"已评价",
	5:"已完成",
	6:"处理中",
	7:"重新处理"
}

//是否逾期
export const istimeout={
	true:"是",
	false:"否"
}

//处理等级
export const level={
	0:"一般",
	1:"紧急",
	2:"非常紧急"
}

//派遣方式
export const dispatchType={
	1:"抢单",
	2:"自动派单",
	3:"人工分配"
}

//上报人类型
export const evaluateType={
	1:"住户",
    2:"员工"
}

//根据id获取报修事件详情
export function getRepairDetail(id){
	return fetch({
		url:`/customer/v1/mgt/repair/detail/${id}`,
		method:"get"
	})
}

//指派工单处理人
export function setDealuser(data){
	return fetch({
		url:`/customer/v1/mgt/dispatch/users`,
		method:"PATCH",
		data
	})
}

//根据小区id、类型id 获取报事事件列表(小区id+类型id)
export function getEventList(id,params){
	return fetch({
		url:`/customer/v1/mgt/complaint/complaintaffairs_byareaid/${id}`,
		method:"get",
		params
	})
}

//根据id获取报事详情
export function getPostItDetail(id){
	return fetch({
		url:`/customer/v1/mgt/complaint/detail/${id}`,
		method:"get"
	})
}

//根据id获取投诉详情
export function getAffairDetail(id){
	return fetch({
		url:`/customer/v2/mgt/affair/${id}`,
		method:"get"
	})
}

//获取小区报修项目统计数据
export function getRepairCount(id){
	return fetch({
		url:`/customer/v1/mgt/repair/affairs_analysis/${id}`,
		method:"get"
	})
}

//获取小区报事项目统计数据
export function getComplaintCount(id){
	return fetch({
		url:`/customer/v1/mgt/complaint/affairs_analysis/${id}`,
		method:"get"
	})
}

//拉取报事类型列表
export function getTypeOfReportList(params){
	return fetch({
		url:"/customer/v1/mgt/complainttype/list",
		method :"get",
		params
	})
}

//新增报事类型
export function addReport(data){
	return fetch({
		url:"/customer/v1/mgt/complainttype",
		method:"post",
		data
	})
}

//删除报事类型
export function deleteReport(type_id){
	return fetch({
		url:`/customer/v1/mgt/complainttype/${type_id}`,
		method:"delete"
	})
}

//通过id拉取报事类别信息
export function getReportDetail(type_id){
	return fetch({
		url:`/customer/v1/mgt/complainttype/${type_id}`,
		method:"get"
	})
}

//修改报事类型
export function updateReport(data){
	return fetch({
		url:"/customer/v1/mgt/complainttype",
		method:"patch",
		data
	})
}

//拉取报修类型列表
export function getTypeOfRepairList(){
	return fetch({
		url:"/customer/v1/mgt/repairtype/list",
		method:"get"
	})
}

//新增报修类型
export function addRepair(data){
	return fetch({
		url:"/customer/v1/mgt/repairtype",
		method:"post",
		data
	})
}

//删除报修类型
export function deleteRepair(type_id){
	return fetch({
		url:`/customer/v1/mgt/repairtype/${type_id}`,
		method:"delete"
	})
}

//根据id拉取报修类型详细
export function getRepairTypeDetail(type_id){
	return fetch({
		url:`/customer/v1/mgt/repairtype/${type_id}`,
		method:"get"
	})
}

//修改报修类别
export function updateRepair(data){
	return fetch({
		url:"/customer/v1/mgt/repairtype",
		method:"patch",
		data
	})
}

//拉取报修项
export function getRepairItemList(type_id,params){
	return fetch({
		url:`/customer/v1/mgt/repairsubjectsbytype/${type_id}`,
		method:"get",
		params
	})
}

//新增保修项
export function addRepairItem(data){
	return fetch({
		url:"/customer/v1/mgt/repairsubject",
		method:"post",
		data
	})
}

//拉取报修项详细
export function getRepairItemDetail(subject_id){
	return fetch({
		url:`/customer/v1/mgt/repairsubject/${subject_id}`,
		method:"get"
	})
}

//修改报修项
export function updateRepairItem(data){
	return fetch({
		url:"/customer/v1/mgt/repairsubject",
		method:"patch",
		data
	})
}

//删除报修项
export function deleteRepairItem(subject_id){
	return fetch({
		url:`/customer/v1/mgt/repairsubject/${subject_id}`,
		method:"delete"
	})
}

//回访重新处理
export function redo(params){
	return fetch({
		url:"/customer/v1/mgt/affair_redo",
		method:"post",
		params
	})
}

//用户报修列表字段映射
export const keyMapping={
	// id:"工单号",
	// subject_name:"报修类型",
	// type_name:"报修类别",
	// commit_time:"上报时间",
	// commit_type:"事件来源",
	// affair_status:"当前状态",
	// commituser_name:"报修人",
	// address:"联系地址",
	// chargeuser_name:"责任人",
	// dealuser_name:"处理人",
	// area_name:"所属小区",
	// areaid:"小区id",
	// chargeuser_id:"责任人id",
	// chargeuser_phone:"责任人电话",
	// commituser_id:"报修人id",
	// commituser_phone:"报修人电话",
	// completetime:"完成时间",
	// dealuser_id:"处理人id",
	// dealuser_phone:"处理人电话",
	// note:"备注",
	// istimeout:"是否逾期",

	// custArea:"片区名称",
	custCorpName:"项目名称",
	_woType:"类别",
	_sum:"数量",
	time:"时间",

	inTimeSum:"及时数量",
	notTimeSum:"不及时数量",
	notTimeRate:"不及时占比",
	notTimes:"不及时周期",
	completeSum:"已完成数量",
	notRate:"未完成占比",
	notTime:"未完成周期",
	general:"中评(占比)",
	good:"好评(占比)",
	poor:"差评(占比)",
	notTimeId:"不及时数量的乐天单号",
	notTimeList:"不及时明细",
	notId:"未完成数量的乐天单号",
	notList:"未完成明细",
	poorList:"差评明细",
	returnSum:"回访数量",
	returnRate:"回访比例",
	list:"投诉明细",
	endSum:"完结量",
	notSum:"未完结量",
	inSum:"呼入数量",
	outSum:"呼出数量",
	leakSum:"漏接数量",
	woStep3Answer:"评价文本",

	woOther1:"工单单号",
	woOther16:"责任人",
	woCreateTime:"开始时间",
	woEndTime:"结束时间",
	timeConsuming:"耗时",
	unfinishedCycle:"未完成周期"
}

//拉取类别管理列表
export function getSubtypeList(params){
	return fetch({
		url:"/customer/v2/mgt/affair_subtype",
		method:"get",
		params
	})
}

//修改类别管理
export function updateSubtype(affairSubtypeId,data){
	return fetch({
		url:`/customer/v2/mgt/affair_subtype/${affairSubtypeId}`,
		method:"patch",
		data
	})
}

//新增工单
export function addAffair(data){
	return fetch({
		url:"/customer/v2/mgt/affair",
		method:"post",
		data
	})
}

//根据区域id拉取区域内中文数据
export function getRegioninfo(params){
	return fetch({
		url:"/customer/v1/region/info",
		method:"get",
		params
	})
}

//强制结束工单
export function affairForceStop(affairId,data){
	return fetch({
		url:`/customer/v2/mgt/affair/${affairId}/force_stop`,
		method:"post",
		data
	})
}

